<!-- 管理学生信息 -->
<template>
	<view class="container">
		<view class="c-cell" @click="toMineStudentInfo">
			<u-cell-group>
				<u-cell v-for="item in studentList" :key="item.id" :data-sn="item.document_nums" icon="order" :title="item.name + (item.relatives_id==0?'':'(教师子女)')" label="点击查看学生信息" value="已完善" size="large"></u-cell>
			</u-cell-group>
		</view>
		<view class="c-empty" v-if="studentList.length==0">
			<u-empty icon="/static/empty/list.png" text="暂无学生信息" textSize="18" marginTop="25%" width="80%"></u-empty>
		</view>
		<view class="c-btn">
			<view class="btn-addition" @click="addStudentInfo"><image src="/static/addition.png" mode=""></image></view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"",
		data() {
			return {
				// 学生列表
				studentList:[],
				query:{
					page:1,
					page_size:10
				}
			}
		},
		onLoad() {
			this.getOrgStudentList()
		},
		onReachBottom(){
			this.query.page+=1
			this.getOrgStudentList()
		},
		methods: {
			// 跳转学生详情
			toMineStudentInfo(e){
				if(e.target.dataset.sn){
					this.navigateTo("/pages/pages_mine/public/mineStudentInfo?sn="+e.target.dataset.sn)
				}
			},
			// 添加学生信息
			addStudentInfo(){
				this.navigateTo("/pages/pages_mine/public/mineStudentInfo?type=add")
			},
			// 获取学生信息列表
			getOrgStudentList(){
				this.$http.getOrgStudentList(this.query).then(res=>{
					if(res.data.length){
						this.studentList = this.studentList.concat(res.data)
					}else{
						uni.$u.toast("没有更多了")
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container{
		.c-btn{
			.btn-addition {
			width: 110rpx;
			height: 110rpx;
			position: fixed;
			right: 30rpx;
			bottom: 80rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			background-color: rgba(0, 0, 0, 0.2);
			border-radius: 100%;

			& > image {
				width: 60rpx;
				height: 60rpx;
			}
		}
		}
	}
</style>
